<% @title = "#{t :lichsumuonsach}" %>
<h3><%= t :lichsumuonsach %></h3>
<%@x = session[:user_id]%>

<%count = 0%>
<%@overdue = Borrowedtable.find(:all, :conditions => ['PayedDate IS NULL'])%>

<%@users    = User.find(:all) %>
<% if(@overdue.count == 0) %>

<h3><%= t :kqmuonsach%></h3>
<%else%>
<font size = '4'> 
<table border="2";> 
  <tr> 
   <th><b><%= t :sott%></b></th>
   <th><b><%= t :tensach%></b></th>
   <th><b><%= t :ngaymuon%></b></th>
   <th><b><%= t :hantrasach%></b></th>
   <h6><th><%= t :tinhtrang%></th></h6>
  </font>   
  </tr>

        <%@overandover = User.find(:first, :conditions => ['id = ? ', @x]) %>
        <%@overover = Borrowedtable.find(:all, :conditions => ['NameOfBorrow = ? ', "#{@overandover.firstName+@overandover.lastName}"]) %>
        <%temp = 0%>
        <%@overover.each do |overover|%>
        <%if(temp == 0)%>    
            <tr> 
            <td><%=count = count+1%></td>  
            <td><%=overover.NameOfBook%></td>
            <td><%=overover.BorrowedDate%></td>
            <td><%=overover.Deadline%></td>
            <% if (overover.PayedDate == nil) %>
              <td><%=t :dangmuon%></td>
            <%else%>
              <td><%=t :datra%></td>
            <% end %>
            </tr> 
            <%temp = temp + 1 %> 
       <%else%>
            <tr> 
            <td><%=count = count+1%></td>  
            <td><%=overover.NameOfBook%></td>
            <td><%=overover.BorrowedDate%></td>
            <td><%=overover.Deadline%></td>
            
            <% if (overover.PayedDate == nil) %>
              <td><%=t :dangmuon%></td>
            <%else%>
              <td><%=t :datra%></td>
            <% end %>
            </tr> 
            <%temp = temp + 1 %> 
    
        <%end%>
       
    
   <%end%>
<%end%>
</table> 
